from django.http import HttpResponse,JsonResponse
import json

def index(request):
    response = HttpResponse('<h1>你妈妈有没有教你礼尚往来,我喜欢你你得喜欢我</h1>',content_type='text/html;charset=utf-8')
    # response.status_code=400
    response['X-Token'] = '91wangfan'
    response.write('91wangfan')
    return response


def json_view(request):
#     persons = [
#     {
#         'username':'sanjinda',
#         'age':18,
#         'height':'180cm',
#     },
#     {
#         'username': '91wangfan',
#         'age': 19,
#         'height': '185cm',
#     }
#
# ]
    persons = ['1','2','3','4']
    # person_str = json.dumps(persons)
    # response = HttpResponse(person_str,content_type='application/json')
    response = JsonResponse(persons,safe=False)
    #默认只能对字典进行序列化成json 非字典 记住加上 safe
    return response